package db_live

import (
	"longmen/server/config/global"
	"longmen/server/pkg/db/mysql/models/models_live"
)

/*type AstrictArea struct {
	model models.AstrictArea
}*/
// GetLiveAstrictArea
func GetLiveAstrictArea(param map[string]string) (*models_live.AstrictArea, error) {
	matchRecords := &models_live.AstrictArea{}
	sql := "SELECT count(1)  as nums FROM `db_astrict_area` "
	var wheres string
	for _, val := range param {
		if len(val) > 0 {
			wheres += " or area like '%" + val + "%' "
		}
	}
	wheres = " where " + wheres[3:]
	err := global.GetR().Raw(sql + wheres).Order("id asc").
		Limit(1).
		Find(matchRecords).Error
	return matchRecords, err
}
